﻿using AutoMapper;
using FoodModel;
using J.FoodManageSet.Application.Command.BenchTableCommand;
using J.FoodManageSet.Application.Command.GroupingCommand;
using J.FoodRepository.InterFace;
using MediatR;

namespace J.FoodManageSet.Application.CommandHandler.BenchTableCommandHandler
{
    /// <summary>
    /// 台费添加
    /// </summary>
    public class BenchTableAddCommandHandler : IRequestHandler<BenchTableAddCommand, int>
    {
        private readonly IBenchTableRepository _benchTableRepository;
        private readonly IMapper _mapper;

        public BenchTableAddCommandHandler(IBenchTableRepository  benchTableRepository, IMapper mapper)
        {
           _benchTableRepository = benchTableRepository;
            _mapper = mapper;
        }

        public async Task<int> Handle(BenchTableAddCommand request, CancellationToken cancellationToken)
        {
            BenchTableModel model = _mapper.Map<BenchTableModel>(request);
            var list = await _benchTableRepository.BenchTableAdd(model);
            return list;
        }
    }
}
